package com.jyniubi.gmail.search.Controller;

import com.jyniubi.gmail.common.bean.ResponseVo;
import com.jyniubi.gmail.search.pojo.SearchRequestVo;
import com.jyniubi.gmail.search.pojo.SearchResponseVo;
import com.jyniubi.gmail.search.service.impl.SearchServiceImpl;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Controller
public class SearchController {

    @Resource
    private SearchServiceImpl searchService;

    @GetMapping("/search")
    private String search(SearchRequestVo requestVo, Model model){
        SearchResponseVo searchResponseVo = this.searchService.search(requestVo);
        model.addAttribute("response",searchResponseVo);
        model.addAttribute("searchParam",requestVo);
        return "search.html";
    }
}
